package com.heima.user.controller.v1;

import com.heima.common.exception.LeadNewsException;
import com.heima.model.common.dto.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.dto.LoginDto;
import com.heima.user.service.ApUserLoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author Ronaldo
 * @date 2021/8/13
 */
@RestController
@RequestMapping("/api/v1/login")
@Slf4j
public class ApUserLoginController {

    @Autowired
    private ApUserLoginService apUserLoginService;

    @PostMapping("/login_auth")
    public ResponseResult apUserLogin(@RequestBody LoginDto loginDto){

        log.info("apUser login by loginDTO",loginDto);

        if (Objects.isNull(loginDto)){
            throw new LeadNewsException(AppHttpCodeEnum.PARAM_INVALID);
        }
        return apUserLoginService.login(loginDto);

    }
}
